package com.zycfc.zsf.boot.mq.rabbitmq.retry;

import java.io.*;
import com.zycfc.zsf.boot.mq.rabbitmq.converter.*;
import java.util.*;
import java.text.*;

public class MessageContent implements Serializable
{
    private static final long serialVersionUID = 1L;
    private String id;
    private String exchangeName;
    private String routingKey;
    private String message;
    private String firstSendTime;
    private String lastSendTime;
    private static final String FORMAT;
    
    public MessageContent(final MessageCache messageCache) {
        if (null == messageCache) {
            throw new RuntimeException("messageCache is null");
        }
        this.id = messageCache.getId();
        this.exchangeName = messageCache.getExchangeName();
        this.routingKey = messageCache.getRoutingKey();
        this.message = JsonMessageConverter.getMessageContent(messageCache.getMessage());
        final DateFormat DATE_FORMAT = new SimpleDateFormat(MessageContent.FORMAT);
        this.firstSendTime = DATE_FORMAT.format(new Date(messageCache.getFirstSendTime()));
        this.lastSendTime = DATE_FORMAT.format(new Date(messageCache.getLastSendTime()));
    }
    
    public void setId(final String id) {
        this.id = id;
    }
    
    public void setExchangeName(final String exchangeName) {
        this.exchangeName = exchangeName;
    }
    
    public void setRoutingKey(final String routingKey) {
        this.routingKey = routingKey;
    }
    
    public void setMessage(final String message) {
        this.message = message;
    }
    
    public void setFirstSendTime(final String firstSendTime) {
        this.firstSendTime = firstSendTime;
    }
    
    public void setLastSendTime(final String lastSendTime) {
        this.lastSendTime = lastSendTime;
    }
    
    public String getId() {
        return this.id;
    }
    
    public String getExchangeName() {
        return this.exchangeName;
    }
    
    public String getRoutingKey() {
        return this.routingKey;
    }
    
    public String getMessage() {
        return this.message;
    }
    
    public String getFirstSendTime() {
        return this.firstSendTime;
    }
    
    public String getLastSendTime() {
        return this.lastSendTime;
    }
    
    static {
        FORMAT = new String("yyyy-MM-dd HH:mm:ss:SSS");
    }
}
